package io.renren.modules.controller;

import com.alibaba.druid.util.StringUtils;
import io.renren.annotation.Login;
import io.renren.common.utils.Result;
import io.renren.modules.service.BsRoomService;
import io.renren.modules.vo.BsProductVO;
import io.renren.modules.vo.BsRoomVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 房间编号
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2024-05-27
 */
@RestController
@RequestMapping("/bsroom")
public class BsRoomController {

    @Autowired
    private BsRoomService bsRoomService;

    @Login
    @ApiOperation("查询可用房间列表，不分页。")
    @PostMapping("/listRoom")
    public Result listRoom() {
        List<BsRoomVO> bsRoomVOS = bsRoomService.listRoom();
        return new Result().ok(bsRoomVOS);
    }

    @Login
    @ApiOperation("根据房间编号，查询可用产品列表，不分页。")
    @PostMapping("/listProductByRoomNo")
    public Result listProductByRoomNo(String roomNo) {
        if (StringUtils.isEmpty(roomNo)) {
            return new Result().error("房间编号为空，请检查。");
        }
        List<BsProductVO> bsRoomVOS = bsRoomService.listProductByRoomNo(roomNo);
        return new Result().ok(bsRoomVOS);
    }


}